﻿/// <reference path="../Core.ts" />

module Supernova {

    export class DialogUI implements UI.ISwitchableUI {

        layout = {
            rootPanel: {
                controls: {
                    mainMenuPanel: {
                        width: 500, height: 300,
                        controls: {
                            messageLabel: {
                                top: 0, height: 40,
                                text: "Message text."
                            },
                            okButton: {
                                top: 80, width: 100, height: 40,
                                text: "OK"
                            }
                        }
                    }
                }
            }
        }

        public root: UI.UIControl = null;

        constructor() {
            this.root = UI.compile(this.layout)[0];
        }

        show() {
        }

        hide() {
        }

        public showMessage = function (text, onClose) {
            UI.swap(dialogUI, UI.Bounds.create(canvas));
            (<UI.Label>UI.getControlByName(UI.root, 'messageLabel')).text = text;
            UI.getControlByName(UI.root, 'okButton').onClick = onClose;
        };

    }

}